home *** CD-ROM | disk | FTP | other *** search
- Path: interramp.com!usenet
- From: us011245@interramp.com
- Newsgroups: comp.lang.c++
- Subject: Re: What is a test harness?
- Date: Mon, 04 Mar 96 20:09:01 PDT
- Organization: PSI Public Usenet Link
- Message-ID: <NEWTNews.18250.826000589.hampton@ip163.herndon7.va.interramp.com>
- References: <313C00F0.51B5@bhp.com.au>
- NNTP-Posting-Host: ip163.herndon7.va.interramp.com
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- X-Newsreader: NEWTNews & Chameleon -- TCP/IP for MS Windows from NetManage
-
-
- In article <313C00F0.51B5@bhp.com.au>, <bowen.richard.rw@bhp.com.au> writes:
- >
- > Somewhere (I can't remember where) I read an article that
- > mentioned test harnesses, but didn't elaborate.
- >
- > What is a test harness and how can you use it to test a class?
- >
- > Thanks,
- >
- > Richard
- >
-
- Plan Alpha
- Let's pretend you want to test some class or group of classes. One of the
- things you can do is to build a new set of classes, one new class corresponding
- to each of the classes you are testing, which simulate the outside world.
- These classes simulate the real inputs your classes receive from the outside
- world and accept the returns from your classes. Likewise, these classes
- provide any "processing" which your classes expect from the outside world and
- return it to your classes. These test classes are basically performing black
- box testing on your target classes. This group of test classes is called a
- parallel testing harness. It's nice because (a) the "real classes" are tested
- and (b) encapsulation is not broken, i.e., we are not "peeking" into the
- innards of the classes under test. The bad news is, as anyone knows who has
- tried to do this, its really time consuming. OK, let's turn to ....
-
- Plan Beta
- Here, we build a set of subclasses corresponding to the classes under test.
- Because these are subclasses, they can "see" all the non-private innards of
- your classes. They can do assertions on the integrity of your classes such as
- (non-private) state/attribute reporting. They can also exercise your classes
- by driving them with specific inputs which may or may not have anything to do
- with real inputs from the outside world. In other word, they do white box
- testing. The good news here is that you can do white box testing, which many
- test people feel is critical, and thet your testing class has access to a much
- more complete picture of what's going on inside your classes. The bad news is,
- you have most definitely broken the encapsulation (and then some) and you are
- faced with the philosophical choice of shipping the system with the inherited
- subclasses or removing them and shipping a system that in some sense you
- haven't really tested. This subclassing is normally called building a derived
- class test harness.
-
- You pay your money and you take your choice..
-
- Regards, Luther Hampton
-
-
-